package com.google.googlemarket.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.google.googlemarket.MyApp;
import com.google.googlemarket.utils.UiUtils;
import com.google.googlemarket.view.stellarmap.StellarMap;

import java.util.ArrayList;
import java.util.Random;

/**
 * Created by Administrator on 2017/9/21.
 */
public class StellarMapAdapter implements StellarMap.Adapter {
    private final ArrayList<String> datas;
    private final Random random;

    public StellarMapAdapter(ArrayList<String> datas) {
        this.datas = datas;
        random = new Random();
    }

    @Override
    public int getGroupCount() {
        return 2;
    }

    @Override
    public int getCount(int group) {
        return 20;
    }

    @Override
    public View getView(int group, int position, View convertView) {
        TextView textView = new TextView(MyApp.getmContext());
        textView.setText(datas.get(position));
        //设置字体大小
        float size = 10 + random.nextInt(17);
        textView.setTextSize(size);
        //设置字体颜色
        int color = UiUtils.createRandomColor();
        textView.setTextColor(color);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TextView tv = (TextView) view;
                Toast.makeText(view.getContext(),tv.getText(),Toast.LENGTH_LONG).show();
            }
        });

        return textView;
    }

    @Override
    public int getNextGroupOnPan(int group, float degree) {
        return 0;
    }

    @Override
    public int getNextGroupOnZoom(int group, boolean isZoomIn) {
        return 0;
    }
}
